package com.spring.config.service.impl;

import com.spring.config.dao.UserRepository;
import com.spring.config.entity.UserJpa;
import com.spring.config.service.IUserService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * ClassName: UserServiceImpl
 * Description:
 * Date: 2017/5/17 11:18
 *
 * @author SAM SHO
 * @version V1.0
 */
@Service
@Transactional(readOnly = true)
public class UserServiceImpl implements IUserService {

    @Resource
    private UserRepository userRepository;


    @Override
    public List<UserJpa> findAll() {
        return userRepository.findAll();
    }

    @Override
    public Page<UserJpa> findByName(String name, String pwd) {
        return userRepository.findByName(name, new PageRequest(1, 10, Sort.Direction.DESC, pwd));
    }
}
